package com.ipay.wechat.core;

import java.util.HashMap;
import java.util.Map;

/**
 * 请求上下文
 * @author yangk
 *
 */
public class RequestContext {
	private static ThreadLocal<RequestContext> rc = new ThreadLocal<RequestContext>();
	private Map<String,Object> ctx = new HashMap<String, Object>();
	
	public static RequestContext get() {
		RequestContext ret = rc.get();
		if (ret == null) {
			RequestContext.set(new RequestContext());
		}
		return ret;
	}
	
	public static void set(RequestContext requestContext) {
		rc.set(requestContext);
	}
	
	public Map<String, Object> put(String key, Object obj) {
		ctx.put(key, obj);
		return ctx;
	}
	
	public Object get(String key) {
		return ctx.get(key);
	}
	
}
